from django.http import HttpResponse
from django.urls import reverse


# Create your views here.


# views.py文件用于编写Web应用视图
def index(request):
    """
    index 视图函数
    :param request: 包含了请求的对象
    :return:响应对象
    """
    return HttpResponse('Hello World!')


def say(request):
    url = reverse("users-list:say")
    print('say func url :{}'.format(url))
    return HttpResponse('say hello!')


def weather(request, city, year):
    print('city:{}'.format(city))
    print('year:{}'.format(year))
    return HttpResponse("weather ok")


# /qs/?a=1&b=2&a=3
def qs(request):
    # a = request.GET.get('a')
    # b = request.GET.get('b')
    # alist = request.GET.getlist('a')
    # print('a:{},b:{},alist:{}'.format(a, b, alist))
    # return HttpResponse('query ok')
    a = request.GET.get('a')
    b = request.GET.get('b')
    alist = request.GET.getlist('a')
    print(a)  # 3
    print(b)  # 2
    print(alist)  # ['1', '3']
    return HttpResponse('OK')
